<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %> 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<meta name="renderer" content="webkit|ie-comp|ie-stand"></meta>
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"></meta>
<meta http-equiv="Cache-Control" content="no-siteapp" />
 <link href="${pageContext.request.contextPath}/adminfile/assets/css/bootstrap.min.css" rel="stylesheet" />
        <link rel="stylesheet" href="${pageContext.request.contextPath}/adminfile/css/style.css"/>       
        <link href="${pageContext.request.contextPath}/adminfile/assets/css/codemirror.css" rel="stylesheet"> </link>
        <link rel="stylesheet" href="${pageContext.request.contextPath}/adminfile/assets/css/ace.min.css"/> 
        <link rel="stylesheet" href="${pageContext.request.contextPath}/adminfile/font/css/font-awesome.min.css"/> 
		<script src="${pageContext.request.contextPath}/adminfile/js/jquery-1.9.1.min.js"></script>
        <script src="${pageContext.request.contextPath}/adminfile/assets/js/bootstrap.min.js"></script>
		<script src="${pageContext.request.contextPath}/adminfile/assets/js/typeahead-bs2.min.js"></script>           	
		<script src="${pageContext.request.contextPath}/adminfile/assets/js/jquery.dataTables.min.js"></script>
		<script src="${pageContext.request.contextPath}/adminfile/assets/js/jquery.dataTables.bootstrap.js"></script>
        <script src="${pageContext.request.contextPath}/adminfile/assets/layer/layer.js" type="text/javascript" ></script>          
        <script src="${pageContext.request.contextPath}/adminfile/assets/laydate/laydate.js" type="text/javascript"></script>
<title>管理员详情</title>
</head>

<body>
<div class="page-content clearfix">
    <div id="Member_Ratings">
      <div class="d_Confirm_Order_style">
    <div class="search_style">
    <!--  <form action="selectByjrTimesupplier" method="post">
      <ul class="search_content clearfix">
       <li><label class="l_f">添加时间</label> <input type="text" name="time"  class="inline laydate-icon" id="start" style=" margin-left:10px;"/></li>
       <li style="width:90px;"><button type="submit" class="btn_search"><i class="icon-search"></i>查询</button></li>
      </ul> 
      </form>-->
    </div>
     <!---->
     <div class="border clearfix">
       <span class="l_f">
        <a href="javascript:ovid()" id="admin_add" class="btn btn-warning"><i class="fa fa-plus"></i>添加管理员</a>
       </span>
       
     </div>
     <!---->
     <div class="table_menu_list">
       <table class="table table-striped table-bordered table-hover" id="sample-table">
<thead>
		 <tr>
				<th width="25"><label><input type="checkbox" class="ace"/><span class="lbl"></span></label></th>
				<th width="100">管理员Id</th>
				<th width="100">登录名</th>
				<th width="150">电话号</th>
				<th width="120">邮箱</th>
				<th width="120">真实姓名</th>                
				<th width="150">操作</th>
			</tr>
		</thead>
            <c:forEach items="${list}" var="p" >
              <tr>
              <th width="25px"><label><input type="checkbox" class="ace"/><span class="lbl"></span></label></th>
              <td id="text_i">${p.adminId}</td>
              <td id="text_n">${p.adminName}</td>
              <td id="text_l">${p.adminTel}</td>
              <td id="text_j">${p.adminEmail}</td>
              <td id="text_h">${p.adminRealName}</td>
               <td class="td-manage">
             <a title="修改" onclick="member_edit('550',this)" href="javascript:;"  class="btn btn-xs btn-info" ><i class="fa fa-edit bigger-120"></i></a>      
             <a title="删除" href="javascript:;"  onclick="member_del(this,'${p.adminId}')" class="btn btn-xs btn-warning" ><i class="fa fa-trash  bigger-120"></i></a>
          </td>
		</tr>
         </c:forEach> 
	</table>
   </div>
  </div>
 </div>
</div>

<!--修改用户图层-->
<div class="add_menber" id="add_menber_style" style="display:none">
  <form action="" method="post" id="form">
  <ul>
   <span class="name"><input type="hidden" id="text0" value="${p.adminId}" name="adminId"/></span>
   <li><label class="label_name">登录名：</label><span class="name"><input id="text1"  type="text" value="${p.adminName}" name="adminName" readonly="readonly"/></span></li>
   <li><label class="label_name">电话号：</label><span class="name"><input  id="text5" type="text"  name="adminTel"value="${p.adminTel}"/></span></li>  
   <li><label class="label_name">邮箱：</label><span class="name"><input id="text6" type="text" value="${p.adminEmail}" name="adminEmail"/></span></li>
   <li><label class="label_name">真实姓名：</label><span class="name"><input id="text7" type="text" value="${p.adminRealName}" name="adminRealName"/></span></li>
  </ul> 
  </form>
 </div>
 <!-- 添加供应商图层 -->
 <div class="admin_style_add margin" id="admin_style_add" style="display:none"> 
   <form action="" method="post" id="form1">
   <ul>
   <li><label class="label_name">登录名：</label><span class="name"><input  id="text1"  type="text" name="adminName"/></span></li>
   <li><label class="label_name">密码：</label><span class="name"><input  id="text2"  type="text" name="adminPassword"/></span></li>
   <li><label class="label_name">电话号：</label><span class="name"><input  id="text5" type="text"  name="adminTel"/></span></li>  
   <li><label class="label_name">邮箱：</label><span class="name"><input  id="text6" type="text"  name="adminEmail"/></span></li>
   <li><label class="label_name">真实姓名：</label><span class="name"><input  id="text7" type="text"  name="adminRealName"/></span></li>
  </ul>
  </form>
  </div>
</body>      
<script type="text/javascript">	
jQuery(function($) {
				var oTable1 = $('#sample-table').dataTable( {
				"aaSorting": [[ 1, "desc" ]],//默认第几个排序
		"bStateSave": true,//状态保存
		"aoColumnDefs": [
		  //{"bVisible": false, "aTargets": [ 3 ]} //控制列的隐藏显示
		  {"orderable":false,"aTargets":[0,2,3,4,5,6]}// 制定列不参与排序
		] } );
				
				
				$('table th input:checkbox').on('click' , function(){
					var that = this;
					$(this).closest('table').find('tr > td:first-child input:checkbox')
					.each(function(){
						this.checked = that.checked;
						$(this).closest('tr').toggleClass('selected');
					});
						
				});
			
			
				$('[data-rel="tooltip"]').tooltip({placement: tooltip_placement});
				function tooltip_placement(context, source) {
					var $source = $(source);
					var $parent = $source.closest('table')
					var off1 = $parent.offset();
					var w1 = $parent.width();
			
					var off2 = $source.offset();
					var w2 = $source.width();
			
					if( parseInt(off2.left) < parseInt(off1.left) + parseInt(w1 / 2) ) return 'right';
					return 'left';
				}
			})
/*用户-添加*/
 $('#admin_add').on('click', function(){
    layer.open({
        type: 1,
        title: '添加管理员',
		maxmin: true, 
		shadeClose: true, //点击遮罩关闭层
        area : ['800px' , ''],
        content:$('#admin_style_add'),
		btn:['提交','取消'],
		yes:function(index,layero){	
		 var num=0;
		 var str="";
     $(".admin_style_add input[type$='text']").each(function(n){
          if($(this).val()=="")
          {
               
			   layer.alert(str+=""+$(this).attr("name")+"不能为空！\r\n",{
                title: '提示框',				
				icon:0,								
          }); 
		    num++;
            return false;            
          } 
		 });
		  if(num>0){  return false;}	 	
          else{
        	$.ajax({
        		type:"POST",
        		url:"addadmin",
        		data:$('#form1').serialize(),
        		success:function(date){
        			if(date=="success")
        				{
        				layer.alert("添加成功！",{
        					title:'提示框',
        					icon:1,
        				});
        				}
        		}	
        	}
        	)
			   layer.close(index);	
		  }		  		     				
		}
    });
});
/*用户-查看*/
function member_show(title,url,id,w,h){
	layer_show(title,url+'#?='+id,w,h);
}
/*用户-编辑*/
function member_edit(id,t){
	  $("#text0").val($(t).closest("tr").find("#text_i").text());
	  $("#text1").val($(t).closest("tr").find("#text_n").text());
	  $("#text5").val($(t).closest("tr").find("#text_l").text());
	  $("#text6").val($(t).closest("tr").find("#text_j").text());
	  $("#text7").val($(t).closest("tr").find("#text_h").text());
	  layer.open({
        type: 1,
        title: '修改管理员信息',
		maxmin: true, 
		shadeClose:false, //点击遮罩关闭层
        area : ['800px' , ''],
        content:$('#add_menber_style'),
		btn:['提交','取消'],
		yes:function(index,layero){	
		 var num=0;
		 var str="";
     $(".add_menber input[type$='text']").each(function(n){
          if($(this).val()=="")
          {
               
			   layer.alert(str+=""+$(this).attr("name")+"不能为空！\r\n",{
                title: '提示框',				
				icon:0,								
          }); 
		    num++;
            return false;            
          } 
		 });
		  if(num>0){  return false;}	 	
          else{
        	  $.ajax({
        	         type: "POST",
        	         url: "updateadmin",
        	         data: $('#form').serialize(),
        	         success: function (date) {
        	        	if(date=="success")
        	        		{
        	        	 layer.alert("修改成功！",{
        	                 title: '提示框',				
        	  			icon:1,		
        	  			  });
        	        	 
        	        	 $(t).closest("tr").find("#text_n").text($("#text1").val());
	                     $(t).closest("tr").find("#text_l").text($("#text5").val());
	                     $(t).closest("tr").find("#text_j").text($("#text6").val());
	                     $(t).closest("tr").find("#text_h").text($("#text7").val());
        	        		}	 
        	         }
        	     })

  			   layer.close(index);
  		  }		  		     				
  		}
      });
  	  
  }

/*用户-删除*/
function member_del(obj,adminId){
	layer.confirm('确认要删除吗？',function(index){
		  $.ajax({
 	         type: "POST",
 	         url: "${pageContext.request.contextPath}/deleteadmin",
 	         data: {"adminId":adminId},
 	         success: function (date) {
 	        	if(date=="success")
 	        		{
 	        		  $(obj).parents("tr").remove();
 	       		      layer.msg('已删除!',{icon:1,time:1000});
 	        		}	 
 	         }
 	     });
	});
}
		//$ajax({
		//	type:"POST",
		//	url:"deletesupplier",
		//	data:{"supplier":supplierId},
		//	success:function (date){
			//	if(date="")
			//		{
					//$(obj).parents("tr").remove();//删除某一行记录
				    //layer.msg('已删除!',{icon:1,time:1000});
			      //  }
			//}
		//});
	//}
//}
laydate({
    elem: '#start',
    event: 'focus' 
});
</script>
</html>